<template>
  <div>
    <van-nav-bar
      title="登录账号"
      left-text="返回"
      right-text="取消"
      left-arrow
      @click-left="$router.go(-1)"
      @click-right="$router.go(-1)"
    />
    <van-form @submit="onSubmit">
      <van-field
        v-model="params.username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="params.password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import { dengLu } from '@/api/user'
import { Toast } from 'vant'
export default {
  name: 'MyLogin',
  components: {},
  props: {},
  data() {
    return {
      params: {
        username: '',
        password: ''
      }
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    async onSubmit(params) {
      // console.log('submit', params)
      const res = await dengLu(params)
      console.log(res)
      Toast(res.description)
    }
  }
}
</script>

<style scoped lang="scss"></style>
